<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="${staticServer}/inc/style/main.css"/>
    <link rel="stylesheet" href="${staticServer}/inc/style/page.css"/>
    <link rel="stylesheet" href="${staticServer}/css/struct_info.css"/>
    <link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css"/>
    <script src="${staticServer}/inc/js/jquery.js"></script>
    <script src="${staticServer}/inc/js/pageset.js"></script>
    <script src="${staticServer}/inc/js/datepicker.js"></script>
    <script src="${staticServer}/inc/js/submitter.js"></script>
    <script src="${staticServer}/inc/js/infopad.js?2.2"></script>
    <script>
        var contextPath = '${contextPath}';
        $(function () {
            $("#form_submit").click(function () {
                var  director = $("#director").val();
                var  keuser = $("#keuser").val();
                var  cdate = $("#cdate").val();
                var  ids = $("#ids").val();
                var  center_msg = $("#center_msg").val();
                if (director == "") {
                    infopad.err("请输入评分!");
                    return false;
                }

                if (keuser == "") {
                    infopad.err("咨询师不能为空!");
                    return false;
                }

                if (cdate == "") {
                    infopad.err("时间不能为空!");
                    return false;
                }
                $.ajax({
                    type: 'POST',
                    url: 'add_grade.htm',
                    data: {"director": director,"keuser": keuser,"cdate": cdate,"ids": ids,"center_msg":center_msg},
                    dataType: "text",
                    success: function (data) {
                        if (data == "success") {
                            infopad.err("保存成功!");
                        } else {
                            infopad.err("保存失败!");
                        }
                    },
                    error: function () {
                        infopad.err("系统出现问题");
                    }
                });


            });
        })
        function querys_user(username, date) {
            var data = {};

            if (username != null && username != "") {
                data.username = username;
            } else {
                data.username = $("#keuser").val();
            }
            if (date != null && date != "") {
                data.cdate = date;
            } else {
                data.cdate = $("#cdate").val();
            }
            if (data.cdate != "" && data.username != "") {
                $.post("${contextPath}/index/query_user.json", data, function (d) {
                    var user = d.usergrade;
                    if (user != null && user != "") {
                        $("#director").attr('value', user.director);
                        $("#charge").attr('value', user.charge);
                        $("#ids").attr('value', user.id);
                    } else {
                        $("#director").attr('value', '');
                        $("#charge").attr('value', '');
                        $("#ids").attr('value', '');
                    }
                }, "json");
            } else {
                $("#director").removeAttr('value');
                $("#charge").removeAttr('value');
                $("#ids").removeAttr('value');
            }
        }

        $("body").ready(function (e) {
            select_date('cdate', dateSelected);
        });

        function select_date(targetid, func) {
            $('#' + targetid).Zebra_DatePicker({format: 'Y-m', show_icon: false, onSelect: func});
        }

        function dateSelected(date) {
            var username = "";
            querys_user(username, date);
        }

        $(function () {
            $("#keuser").val('<#if usergrade??>${usergrade.username}</#if>');
            $("#ids").val('<#if usergrade??>${usergrade.id}</#if>');
        })

        function addOffice() {
            window.location.href = "${contextPath}/index/look_grade.htm?flag=2";
        }
        function judgeNumber() {
            if (Number($("#director").val()) > 10) {
                infopad.err("分值最大为10!");
                $("#director").val("");
            }

        }
    </script>
</head>
<style>
    table tr[class=fields] th {
        color: #A65BC1;
        font-size: 16px;
        font-weight: bold;
        text-align: center;
    }

    table tr th {
        color: #999;
        font-size: 14px;
        font-weight: bold;
        text-align: right;
        width: 15%;
    }

    table td {
        font-size: 14px;
        padding-top: 10px;
        padding-bottom: 10px;
        line-height: 25px;
    }
</style>
<body>
<input type="hidden" id="ids">
<div id="container">
    <div id="home_link">
        <ul>
            <li></li>
            <li>&gt;</li>
            <li>中心评分</li>
            <li>&gt;</li>
            <li class="current"></li>
        </ul>
    </div>
    <table class="form_table">
        <tr>
            <td>
                <label>查询咨询老师评分：</label>
                <input id="btnAdd" onclick="addOffice()" type="button" value="查询我的打分 ">
            </td>
        </tr>
    </table>
    <table id="infotable">
        <tr>
            <th width="25%">年月时间</th>
            <td width="75%">
                <input type="text" name=" " id="cdate" size="15" value="<#if cdate??>${cdate}</#if>" rel="DATE::Y-m"/>
            </td>
        </tr>

        <tr>
            <th width="25%">咨询老师</th>
            <td width="75%">
                <select name="keuser" id="keuser" onchange="querys_user(this.value,'')">
                    <option value="">-- 请选择咨询老师--</option>
                <#if uList??>
                    <#list uList as list>
                        <option value="${list.username}">${list.nickname}
                            （${list.regions}-${list.departments}-${list.job}）
                        </option>
                    </#list>
                </#if>
                </select>
            </td>
        </tr>

        <tr>
            <th>中心主任评分</th>
            <td>
                <input id="director" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')"
                       onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')"
                       onblur="judgeNumber()" type="money" size="20"
                       value="<#if usergrade??>${usergrade.director}</#if>" maxlength="30"/> 分 &nbsp;&nbsp;&nbsp;(总分10分，根据日常工作、工作态度、团队精神等进行打分)
            </td>

        </tr>
        <tr>
            <th>说明:</th>
            <td>
                <textarea id="center_msg" style="margin: 0px; width: 745px; height: 271px;" placeholder="">无</textarea>
            </td>

        </tr>

    </table>
    <div id="controlbar">
        <input type="button" class="submit" id="form_submit" value=" 保存  "/>
    </div>
</div>
</body>
</html>